package net.zjitc.dao.impl;

import net.zjitc.dao.UserDao;
import net.zjitc.daomain.User;
import org.springframework.stereotype.Repository;

/**
 * Created by Administrator on 2017/2/27.
 */
@Repository
public class UserDaoImpl implements UserDao {
    private User[] users = new User[3];

    public void init() {
        users[0] = new User(1, "duwang", "duwang");
    }

    @Override
    public User findDaoNamePassword(String username, String password) {
        this.init();
        for (User u : users) {
            if (u.getName().equals(username) && u.getPassword().equals(password)) {
                return u;
            }
            return null;
        }
        return null;
    }

    @Override
    public User findDaoZhuceNamePassword(String username, String password) {
        this.init();
        for (User u : users) {
            if (u.getName().equals(username) ) {
                return null;
            }
            else{
                return u;
            }
        }
        return null;
    }}
